//
//  AppDelegate.m
//  Travel_M_Travel
//
//  Created by APPLE10 on 15-3-21.
//  Copyright (c) 2015年 lanou3g.com 蓝鸥科技. All rights reserved.
//

#import "AppDelegate.h"
#import "UIColor+AddColor.h"
#import "AFNetworkReachabilityManager.h"
#import "MyViewController.h"
@interface AppDelegate ()

@end

@implementation AppDelegate


-(void)dealloc
{
    [_window release];
    [super dealloc];
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    // Override point for customization after application launch.
    self.window.backgroundColor = [UIColor whiteColor];
    
    [self.window makeKeyAndVisible];
    [_window release];
    
    
    JourneyViewController *jourVC = [[JourneyViewController alloc]init];
    jourVC.title = @"旅行";
    jourVC.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"旅行" image:[[UIImage imageNamed:@"journeyN.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] selectedImage:[[UIImage imageNamed:@"journeyS.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
    UINavigationController *jourNC = [[UINavigationController alloc]initWithRootViewController:jourVC];
    
    MusicViewController *musicVC = [[MusicViewController alloc]init];
    musicVC.title = @"音乐";
    musicVC.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"音乐" image:[[UIImage imageNamed:@"musicN.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] selectedImage:[[UIImage imageNamed:@"musicS.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
    UINavigationController *musicNC = [[UINavigationController alloc]initWithRootViewController:musicVC];
    
    RecommendViewController *recommendVC = [[RecommendViewController alloc]init];
    recommendVC.title = @"推荐";
    recommendVC.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"推荐" image:[[UIImage imageNamed:@"recommendN.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] selectedImage:[[UIImage imageNamed:@"recommendS.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
    UINavigationController *recommendNC = [[UINavigationController alloc]initWithRootViewController:recommendVC];
    
    MyViewController *myVC = [[MyViewController alloc] init];
    myVC.title = @"我";
    myVC.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"个人中心" image:[[UIImage imageNamed:@"wotupian.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] selectedImage:[[UIImage imageNamed:@"wowenzi.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
    UINavigationController *myNC = [[UINavigationController alloc] initWithRootViewController:myVC];
    
    
    
    // 不显示导航栏宽度, 两句都可以
    recommendNC.navigationBar.translucent = NO;
    //    recommendVC.automaticallyAdjustsScrollViewInsets = NO;
    UITabBarController *tabBC = [[UITabBarController alloc]init];
<<<<<<< HEAD
    tabBC.tabBar.barTintColor = [UIColor colorFromHexCode:@"#a1a3a6"];
    tabBC.tabBar.tintColor = [UIColor colorFromHexCode:@"#65c294"];
=======
    tabBC.tabBar.barTintColor = [UIColor colorFromHexCode:@"#afb4db"];
    tabBC.tabBar.tintColor = [UIColor cyanColor];
>>>>>>> 685ed07e3420b5801f78117f996654b58c63d95c
    self.window.rootViewController = tabBC;
    tabBC.viewControllers = @[recommendNC , jourNC, musicNC, myNC];
    
    
//    // 网络状态判断
//    AFNetworkReachabilityManager *rm = [AFNetworkReachabilityManager sharedManager];
//    [[AFNetworkReachabilityManager sharedManager] setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) {
//        if (rm.networkReachabilityStatus == -1) {
//            UIAlertView *al = [[UIAlertView alloc] initWithTitle:@"提示" message:@"当前网络状态未知" delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil];
//            [al show];
//        }else if (rm.networkReachabilityStatus == 0) {
//            UIAlertView *al = [[UIAlertView alloc] initWithTitle:@"提示" message:@"无服务" delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil];
//            [al show];
//        }else if (rm.networkReachabilityStatus == 1) {
//            UIAlertView *al = [[UIAlertView alloc] initWithTitle:@"提示" message:@"当前网络状态为2G/3G/4G" delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil];
//            [al show];
//        } else if (rm.networkReachabilityStatus == 2) {
//            UIAlertView *al = [[UIAlertView alloc] initWithTitle:@"提示" message:@"当前网络状态为Wifi" delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil];
//            [al show];
//        }
//        
//    }];
    
    //开始监控
    [[AFNetworkReachabilityManager sharedManager] startMonitoring];
    
    [jourNC release];
    [jourVC release];
    [musicNC release];
    [musicVC release];
    [recommendNC release];
    [recommendVC release];
    [myVC release];
    [myNC release];
    [tabBC release];
    
    
    return YES;
}

- (void)applicationWillResignActive:(UIApplication *)application {
    // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
    // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}

- (void)applicationDidEnterBackground:(UIApplication *)application {
    // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

- (void)applicationWillEnterForeground:(UIApplication *)application {
    // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}

- (void)applicationDidBecomeActive:(UIApplication *)application {
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

- (void)applicationWillTerminate:(UIApplication *)application {
    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}

@end
